<?php

function doInstall() {

    if($_SESSION['is_install'] != 1)
        return false;

	require_once "conn.php";

	$sql_contents = "	
	
	DROP TABLE IF EXISTS `users`;
		
	CREATE TABLE IF NOT EXISTS `users` (
	  `id` INT NOT NULL AUTO_INCREMENT ,
	  `u` VARCHAR(45) NOT NULL ,
	  `p` VARCHAR(200) NOT NULL ,
	PRIMARY KEY (`id`) );

	DROP TABLE IF EXISTS `modules`;
	
	CREATE TABLE IF NOT EXISTS `modules` (
	  `id` int(11) NOT NULL auto_increment,
	  `name` varchar(45) collate utf8_bin default NULL,
	  `img` varchar(100) collate utf8_bin NOT NULL,
	  `e` varchar(45) collate utf8_bin default NULL,
	PRIMARY KEY  (`id`) );

	INSERT INTO `modules` (`id`,`name`,`img`,`e`) VALUES (1,'users','img/users.png','users');
	INSERT INTO `modules` (`id`,`name`,`img`,`e`) VALUES (2,'login','img/login.jpg','login');
	INSERT INTO `modules` (`id`,`name`,`img`,`e`) VALUES (5,'intro','img/intro.jpg','intro');
	INSERT INTO `modules` (`id`,`name`,`img`,`e`) VALUES (6,'menu','img/menu.jpg','menu');
	INSERT INTO `modules` (`id`,`name`,`img`,`e`) VALUES (7,'contactus','img/thumpContact.png','contact');
	INSERT INTO `modules` (`id`,`name`,`img`,`e`) VALUES (8,'cool93g','img/thumpCool93.png','cool93g');
	INSERT INTO `modules` (`id`,`name`,`img`,`e`) VALUES (9,'COOL Outing 7 สะระตี่','img/7.jpg','7');
	INSERT INTO `modules` (`id`,`name`,`img`,`e`) VALUES (10,'อิ๊งค์ EAT ALL AROUND','img/eatallaround.jpg','eatallaround');
	INSERT INTO `modules` (`id`,`name`,`img`,`e`) VALUES (11,'COOL Music Alive','img/musicalive.jpg','musicalive');
	INSERT INTO `modules` (`id`,`name`,`img`,`e`) VALUES (12,'Activation','img/thumpActivation.png','activation');
	INSERT INTO `modules` (`id`,`name`,`img`,`e`) VALUES (13,'COOL latitude','img/thumpLatitude.png','latitude');
	INSERT INTO `modules` (`id`,`name`,`img`,`e`) VALUES (14,'Prices & Details','img/thumpPrice.png','price');
	INSERT INTO `modules` (`id`,`name`,`img`,`e`) VALUES (15,'Prices & Details [iPhone]', 'img/thumpPrice.png', 'price_iphone');
	
	";

	$sql_contents = explode(";", $sql_contents);
	
	foreach ($sql_contents as &$sql) {
		$result = mysql_query($sql);
	}
	
    $_SESSION['is_install'] = 0;
    
	return true;
}
?>